/*
 * @lc app=leetcode.cn id=98 lang=golang
 *
 * [98] 验证二叉搜索树
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */

func isValidBST(root *TreeNode) bool {
	return helper(root,-1<<31,1<<31-1)
}

func helper(root *TreeNode,min int,max int)bool{
	if root==nil{
		return true
	}

	if root.Val<min || root.Val>max{
		return false
	}

	return helper(root.Left,min,root.Val-1) && helper(root.Right,root.Val+1,max)
}



// @lc code=end

